package demo.jdbc.model;

import java.sql.Blob;
import java.sql.Types;
import java.util.Date;
import java.util.List;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

    public class Bookmark {
	
	/**
	 * An id from database; included because of technical reasons, 
	 * not because bookmarks really need id's. 
	 */
	protected long id;
	
	/**
	 * The URL address itself as a string
	 */
	protected String url;
	
	/**
	 * The title of the resource
	 */
	protected String title;
	
	/**
	 * The fingerprint of the Web page content
	 * (used to discover different URLs that lead
	 * to identical documents)
	 */
	protected long checksum;
	
	/**
	 * The date when the resource was last changed
	 */
	protected Date lastModified;
	
	/**
	 * The content of the Web page
	 */
	protected String content;
	
	protected FileInputStream bs;
	//protected Blob bs;
	/**
	 * User-given description of the Web page
	 */
	protected String description;

	/**
	 * User-provided "tags" (short keywords or characteristic
	 * strings) identifying the resource. 
	 */
	protected List<Tag> tags;
	
	protected byte[] attachment;
	public Bookmark() {
	}
	
	public Bookmark(String url, String title, String attFN) throws IOException {
		this.url = url;
		this.title = title;
        setAttachment(attFN);
	}
	
	public void setAttachment(String fileName) throws IOException
	{
		
		File file = new File(fileName);
		FileInputStream fs = new FileInputStream(file);
		//Blob b;
		
		
		
		//bs.read(attachment);
		//bs.close();
	}
	
	public FileInputStream getAttachment()
	{
		return bs;
	}
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public List<Tag> getTags() {
		return tags;
	}

	public void setTags(List<Tag> tags) {
		this.tags = tags;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public long getChecksum() {
		return checksum;
	}

	public void setChecksum(long checksum) {
		this.checksum = checksum;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getLastModified() {
		return lastModified;
	}

	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String toString() {
		return "<" + url + ">";
	}
	
}
